class Solution(object):
    def countElements(self, arr):
        s = set(arr)
        return sum([t + 1 in s for t in arr])